from page.net_project_page import NetProjectPage
from common.page import XPATH
import time as t
import random as r


class NetChoosePage(NetProjectPage):

    def choose_capability(self):
        """选择微能力点"""
        self.swipe_dr('up')
        options = self.find_elements(XPATH, '//XCUIElementTypeSwitch')
        for each in r.sample(options, 3):
            each.click()
        self.find_static_text("选好了，确认提交").click()
        t.sleep(2)
        self.find_element(XPATH, '//XCUIElementTypeWebView'
                                 '/XCUIElementTypeOther'
                                 '/XCUIElementTypeOther'
                                 '/XCUIElementTypeImage').click()

    def choose_capability_fit(self):
        """进入项目后直接去选点"""
        self.find_button("去查看").click()
        self.find_static_text("符合,去选点").click()
        t.sleep(3)
        self.choose_capability()

    def choose_capability_not_fit_application(self):
        """提交更换环境申请"""
        self.find_button("去查看").click()
        self.find_static_text("不符合去申请").click()
        t.sleep(1)
        self.find_static_text("智慧学习环境").click()
        t.sleep(2)
        self.find_static_text("选好了，提交申请")
        t.sleep(1)
        self.find_static_text("确定").click()

    def choose_capability_not_fit_submit(self):
        """变更后提交申请"""
        self.find_button("去选点").click()
        self.choose_capability()
